{include file="public/header" /}
<style>
    /*缩略图高度*/
    .layui-table-cell {height: 36px;line-height: 36px}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_sheng" lay-search="" class="layui-input search" id="province"  lay-filter="province">
                                <option value="">---- 请选择省 ----</option>
                                {foreach name="province" item="vo"}
                                <option value="{$vo.district_id}" >{$vo.district}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_shi" lay-search="" class="layui-input search"  id="city"  lay-filter="city">
                                <option value="">---- 请选择市 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_qu" lay-search="" class="layui-input search"  id="district"  lay-filter="district">
                                <option value="">---- 请选择区 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="user_gender" class="layui-input">
                                <option value="" >不限性别</option>
                                <option value="1">男</option>
                                <option value="2">女</option>
                                <option value="3">未知</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="start_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册开始时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册结束时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="login_start_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="最后登录开始时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="login_end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="最后登录结束时间" />
                        </div>

<!--                        <div class="layui-input-inline layui-form" style="margin-top: 5px">-->
<!--                            <select name="user_bo_role" class="layui-input">-->
<!--                                <option value="" >不限脖脸皮系统身份</option>-->
<!--                                <option value="1">普通用户</option>-->
<!--                                <option value="2">自由创业者</option>-->
<!--                                <option value="3">团员</option>-->
<!--                                <option value="4">团队长</option>-->
<!--                            </select>-->
<!--                        </div>-->

<!--                        <div class="layui-input-inline layui-form" style="margin-top: 5px">-->
<!--                            <select name="user_bo_district_role" class="layui-input">-->
<!--                                <option value="" >不限脖脸皮代理身份</option>-->
<!--                                <option value="1">普通用户</option>-->
<!--                                <option value="2">县级运营商</option>-->
<!--                                <option value="3">市级分公司</option>-->
<!--                                <option value="4">省级子公司</option>-->
<!--                            </select>-->
<!--                        </div>-->

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="user_rule" class="layui-input">
                                <option value="" >不限角色</option>
                                <option value="1">普通用户</option>
                                <option value="2">特惠商品用户</option>
                                <option value="3">脖脸皮用户</option>
                                <option value="4">特惠商品&脖脸皮用户</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="th_rule" lay-search="" class="layui-input search">
                                <option value="">---- 不限福利权限 ----</option>
                                {foreach name="rule" item="vo1"}
                                <option value="{$vo1.rule_id}" >{$vo1.rule_name}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="keyword" placeholder="用户ID|手机号|姓名|昵称"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                    </div>
                </div>
            </div>
            <div class="row">

                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('添加业务员', '{:url('memberAdd')}');">
                            <i class="fa fa-plus"></i> 添加业务员
                        </button>
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"> 导出选中数据</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"> 全部导出</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="batchUpdateRule"> 修改福利权限</a></li>
                        </ul>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--状态模板-->
                    <script type="text/html" id="staBar">
                        <input type="checkbox" value="{{d.user_id}}"  lay-skin="switch"  lay-text="启用|禁用" lay-filter="OnOff" {{ d.user_index == 2 ? 'checked' : '' }}  >
                    </script>
                    <!--状态模板-->
                    <script type="text/html" id="staBar2">
                        <input type="checkbox" value="{{d.user_id}}"  lay-skin="switch"  lay-text="启用|禁用" lay-filter="OnOff2" {{ d.user_submit == 2 ? 'checked' : '' }}  >
                    </script>
                    <!--状态模板-->
                    <script type="text/html" id="staBar3">
                        <input type="checkbox" value="{{d.user_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff3" {{ d.user_teacher == 2 ? 'checked' : '' }}  >
                    </script>
                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                    </script>
                    <!--性别-->
                    <script type="text/html" id="user_sex">
                        {{# if(d.user_gender == 1){ }}
                        <span style="color: green">男</span>
                        {{# } }}
                        {{# if(d.user_gender == 2){ }}
                        <span style="color: red">女</span>
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="user_status">
                        {{# if(d.user_status == 1){ }}
                        <span style="color: green">正常</span>
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        <span style="color: red">已冻结</span>
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="user_bo_role">
                        {{# if(d.user_bo_role == 1){ }}
                        普通用户
                        {{# } }}
                        {{# if(d.user_bo_role == 2){ }}
                        <span style="color: green">自由创业者</span>
                        {{# } }}
                        {{# if(d.user_bo_role == 3){ }}
                        <span style="color: red">团员</span>
                        {{# } }}
                        {{# if(d.user_bo_role == 3){ }}
                        <span style="color: orange">团队长</span>
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="user_rule">
                        {{# if(d.user_rule == 1){ }}
                        普通用户
                        {{# } }}
                        {{# if(d.user_rule == 2){ }}
                        <span style="color: green">特惠商品</span>
                        {{# } }}
                        {{# if(d.user_rule == 3){ }}
                        <span style="color: red">脖脸皮</span>
                        {{# } }}
                        {{# if(d.user_rule == '2,3'){ }}
                        <span style="color: orange;">特惠商品&脖脸皮</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="giftbag_role">
                        {{# if(d.user_giftbag_role == 1){ }}
                        <span style="color: green">否</span>
                        {{# } }}
                        {{# if(d.user_giftbag_role == 2){ }}
                        <span style="color: red">是</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="user_giftbag_level">
                        {{# if(d.user_giftbag_level == 1){ }}
                        普通用户
                        {{# } }}
                        {{# if(d.user_giftbag_level == 2){ }}
                        <span style="color: green">推广丽人</span>
                        {{# } }}
                        {{# if(d.user_giftbag_level == 3){ }}
                        <span style="color: red">自由创业者</span>
                        {{# } }}
                    </script>

                    <script type="text/html" id="opeBar">
                        {{# if(d.user_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('down')}','确定冻结吗?')" class="btn btn-primary btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('up')}','确定启用吗?')" class="btn btn-warning btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('appMemberDetail')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        <!--<a href="javascript:;" onclick="wk.layer_show('充值', '{:url('userRecharge')}?user_id={{d.user_id}}')" class="btn layui-btn-normal btn-xs m-r-xs" title="充值">充值</a>-->
                        <a href="javascript:;" onclick="wk.layer_show('设置区域', '{:url('setDistrict')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="设置区域">设置区域</a>

                        {{# if(d.user_is_shopkeeper == 2 || d.user_is_shopkeeper == 3){ }}
                        <a href="javascript:;" onclick="wk.layer_show('设置店长', '{:url('setShopkeeper')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="设置店长">设置店长</a>
                        {{# } }}
                        {{# if(d.user_is_shopkeeper == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('cancelShopkeeper')}','确定撤销店长？')" class="btn btn-primary btn-xs m-r-xs" title="撤销店长">撤销店长</a>
                        {{# } }}

                        {{# if(d.user_is_shopkeeper == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('cancelShopUser')}','确定撤销店员？')" class="btn btn-primary btn-xs m-r-xs" title="撤销店员">撤销店员</a>
                        {{# } }}
                        {{# if(d.have_store == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('openStore')}','确定开通店铺？')" class="btn btn-primary btn-xs m-r-xs" title="开通店铺">开通店铺</a>
                        {{# } }}
                        <!--<a href="javascript:;" onclick="wk.layer_show('课程积分', '{:url('classBalance')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="课程积分">课程积分</a>-->
<!--                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('memberDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除"><i class="fa fa-trash-o">删除</i></a>-->
                        <a href="javascript:;" onclick="wk.layer_show('私人订制库存', '{:url('privateStock')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="库存">库存</a>
                        {{# if(d.user_giftbag_invite_other != 0){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('relieveUp')}', '确定解除绑定礼包上级？')" class="btn btn-danger btn-xs m-r-xs" title="解除绑定礼包上级">解除绑定</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Member/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'user_id', width: 60, title: 'ID', align: 'center'}
                , {field: 'user_username', width: 100, title: '昵称', align: 'center'}
                , {field: 'user_real_name', width: 90, title: '姓名', align: 'center'}
                , {field: 'user_phone', width: 120, title: '手机号码', align: 'center'}
                , {field: 'user_image', width: 90, title: '头像', align: 'center', templet: '#imgTpl'}
                , {field: 'user_gender', width: 70, title: '性别', align: 'center', templet: '#user_sex'}
                , {field: 'user_rule', width: 90, title: '用户角色', align: 'center', templet: '#user_rule'}
                // , {field: 'user_bo_role', width: '', title: '脖脸皮系统身份', align: 'center', templet: '#user_bo_role'}
                // , {field: 'district_role', width: '', title: '脖脸皮代理身份', align: 'center'}
                , {field: 'rule_name', width: 120, title: '福利权限', align: 'center'}
                , {field: 'user_giftbag_level', width: 100, title: '礼包等级', align: 'center', templet: '#user_giftbag_level'}
                , {field: 'user_area_str', width: 150, title: '地区', align: 'center'}
                // , {field: 'user_giftbag_role', width: 90, title: '面膜权益', align: 'center', templet: '#giftbag_role'}
                , {field: 'user_time', width: '', title: '注册时间', align: 'center'}
                , {field: 'user_giftbag_store_time', width: 160, title: '加入会员时间', align: 'center'}
//                , {field: 'user_index', width: 90, title: '查询权限', align: 'center',fixed: 'right',toolbar: '#staBar'}
//                , {field: 'user_submit', width: 90, title: '报备权限', align: 'center',fixed: 'right',toolbar: '#staBar2'}
                , {field: 'user_teacher', width: 90, title: '是否老师', align: 'center',fixed: 'right',toolbar: '#staBar3'}
                , {fixed: 'right', width:440, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("user_index")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff2)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("user_submit")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff3)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("user_teacher")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect(-1,$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //批量修改福利权限
            batchUpdateRule:function () {
                userIds = getIds();
                if(userIds.length == 0){
                    alert('请选择需要修改的数据');
                }else {
                    wk.layer_show('批量修改分类', "{:url('admin/Member/batchUpdateRule')}?ids=" + userIds);
                }

            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>